import java.util.*;

public class Solution939 {
    public int minAreaRect(int[][] points) {
        Map<Integer, List<Integer>> map=new HashMap<>();
        for (int[] point : points) {
            map.putIfAbsent(point[0],new ArrayList<>());
            map.get(point[0]).add(point[1]);
        }
        for (Integer integer : map.keySet()) {
            map.get(integer).sort(Comparator.comparingInt(a -> a));
        }
        int ans=Integer.MAX_VALUE;
        List<Integer> l=new ArrayList<>(map.keySet());
        for (int i=0;i<l.size();i++){
            List<Integer> ll=map.get(l.get(i));
            for (int j=i+1;j<l.size();j++){
                List<Integer> lll=map.get(l.get(j));
                for (int k=0;k<ll.size();k++){
                    for (int p=k+1;p<ll.size();p++){
                        if (lll.contains(ll.get(k)) && lll.contains(ll.get(p))){
                            ans=Math.min(ans,(ll.get(p)-ll.get(k))*Math.abs(l.get(i)-l.get(j)));
                        }
                    }
                }
            }
        }
        return ans==Integer.MAX_VALUE?0:ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution939().minAreaRect(new int[][]{{1,1},{1,3},{3,1},{3,3},{2,2}}));
    }
}
